package com.rjwh.dingdong.client.activity.more;

import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.Toolbar;
import android.widget.EditText;

import com.aishua.lib.utils.AsStrUtils;
import com.rjwh.dingdong.client.R;
import com.rjwh.dingdong.client.activity.BaseActivity;
import com.rjwh.dingdong.client.mvp.presenter.impl.MoreFeedBackPresenter;
import com.rjwh.dingdong.client.mvp.view.MoreFeedBackView;
import com.rjwh.dingdong.client.util.ToastUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author Kay
 * @ClassName MoreFeedBackActivity
 * @Description
 * @date 2016-7-13
 * @history 2016-7-13 author: description:
 */
public class MoreFeedBackActivity extends BaseActivity implements MoreFeedBackView {
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.app_bar_layout)
    AppBarLayout appBarLayout;
    @BindView(R.id.person_data_et)
    EditText personDataEt;

    private MoreFeedBackPresenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.more_feed_back_layout);
        ButterKnife.bind(this);
        initToolbarHelper();
        presenter = new MoreFeedBackPresenter(this, this);
    }

    private void initToolbarHelper() {
        this.setSupportActionBar(this.toolbar);
        getSupportActionBar().setTitle(getResources().getString(R.string.more_feed_back));
        getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    @OnClick(R.id.person_data_login_out_btn)
    public void onClick() {
        doLeaveMes();
    }

    private void doLeaveMes() {
        String content = personDataEt.getText().toString();
        if (AsStrUtils.isEmpty(content)) {
            ToastUtil.showToast(this, "请输入内容");
        } else {
            presenter.doLeaveMessage(content);
        }

    }

    @Override
    public void showLoading() {
        showLoadDialog();
    }

    @Override
    public void dismissLoading() {
        dismissLoadDialog();
    }

    @Override
    public void FinishActivity() {
        this.finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.detachView();
    }
}
